//
//  SWHDetailTankTableViewCell.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/7/25.
//

import UIKit

class SWHDetailTankTableViewCell: TableViewCell {
    let typeImageView = UIImageView()
    var cntLabel: PaddingLabel = {
        let view = PaddingLabel()
        view.paddingTop = 2
        view.paddingBottom = 2
        return view
    }()
    let brandLabel = ContentLabel(R.font.interRegular(size: 13))
    let modelLabel = ContentLabel(R.font.interSemiBold(size: 15))
    let isSecondHandLabel = ContentLabel(R.font.interRegular(size: 13))
    let isMoreThanOneLabel = ContentLabel(R.font.interRegular(size: 13))
    override func setUpviews() {
        self.contentView.addSubview(typeImageView)
        typeImageView.snp.makeConstraints { make in
            make.top.equalTo(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalToSuperview()
            make.height.width.equalTo(40)
        }
        //
        cntLabel.layer.cornerRadius = 10
        cntLabel.clipsToBounds = true
        cntLabel.backgroundColor = UIColor(hexStr: Constant.ThemeColorHexStr)
        cntLabel.textColor = UIColor.white
        cntLabel.setFont(R.font.sfProTextMedium(size: 13))
        self.contentView.addSubview(cntLabel)
        cntLabel.snp.makeConstraints { make in
            make.top.equalTo(typeImageView)
            make.left.equalTo(typeImageView.snp.right).offset(15)
            make.height.width.greaterThanOrEqualTo(0)
        }
        modelLabel.numberOfLines = 0
        modelLabel.textAlignment = .left
        self.contentView.addSubview(modelLabel)
        modelLabel.snp.makeConstraints { make in
            make.top.equalTo(cntLabel.snp.bottom).offset(10)
            make.left.equalTo(cntLabel)
            make.right.equalTo(-16)
            make.height.greaterThanOrEqualTo(0)
        }
        brandLabel.numberOfLines = 0
        brandLabel.textAlignment = .left
        self.contentView.addSubview(brandLabel)
        brandLabel.snp.makeConstraints { make in
            make.top.equalTo(modelLabel.snp.bottom).offset(6)
            make.left.right.equalTo(modelLabel)
            make.height.greaterThanOrEqualTo(0)
        }
        //isSecondHandTitle
        let isSecondHandTitle = ContentLabel(R.font.interRegular(size: 13), hexStr: "#292D32B2")
        isSecondHandTitle.textAlignment = .left
        isSecondHandTitle.text = "Second Hand Water Heater?"
        self.contentView.addSubview(isSecondHandTitle)
        isSecondHandTitle.snp.makeConstraints { make in
            make.top.equalTo(brandLabel.snp.bottom).offset(6)
            make.left.equalTo(brandLabel)
            make.height.greaterThanOrEqualTo(0)
        }
        //
        self.contentView.addSubview(isSecondHandLabel)
        isSecondHandLabel.snp.makeConstraints { make in
            make.centerY.equalTo(isSecondHandTitle)
            make.right.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)
        }
        let isMoreThanOneTitle = ContentLabel(R.font.interRegular(size: 13), hexStr: "#292D32B2")
        isMoreThanOneTitle.textAlignment = .left
        isMoreThanOneTitle.text = "More Than One SWH/ASHP?"
        self.contentView.addSubview(isMoreThanOneTitle)
        isMoreThanOneTitle.snp.makeConstraints { make in
            make.top.equalTo(isSecondHandTitle.snp.bottom).offset(6)
            make.left.equalTo(brandLabel)
            make.height.width.greaterThanOrEqualTo(0)
            make.bottom.equalTo(-CREATEJOB_REVIEW_INTERNAL)
        }
        self.contentView.addSubview(isMoreThanOneLabel)
        isMoreThanOneLabel.snp.makeConstraints { make in
            make.centerY.equalTo(isMoreThanOneTitle)
            make.right.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)
        }
    }
    func setData(_ model: InstallationDetailSystemDetailForHeaterModel,firstRowFlag: Bool = false){
        self.cntLabel.text = "\(model.number_heaters)x"
        self.brandLabel.text = model.brand
        self.modelLabel.text = model.model
        self.isSecondHandLabel.text = (model.second_hand_flg ? "Yes" : "No")
        self.isMoreThanOneLabel.text = (model.multi_heater_flg ? "Yes" : "No")
        //第一行显示image
        if firstRowFlag {
            self.typeImageView.image = R.image.swhdetail_systeminfo_tank_icon()
        }else{
            self.typeImageView.image = nil
        }
    }
}
